#!/usr/bin/env python

import pygame
from pygame.locals import *

import sys
import Numeric as N

if __name__ == "__main__":
  pygame.init()
  
  screen = pygame.display.set_mode((800, 600))
  screen.fill((0, 0, 0))
  
  surface = pygame.image.load('junai.png').convert_alpha()
  
  rgbarr = pygame.surfarray.pixels3d(surface)
  
  grayscale = N.array(rgbarr)
  
  
  grayscale[:,:,0] = rgbarr[:,:,0] / 10 * 3 + rgbarr[:,:,1] / 10 * 5.9 + rgbarr[:,:,2] / 10 * 1.1
  grayscale[:,:,1] = rgbarr[:,:,0] / 10 * 3 + rgbarr[:,:,1] / 10 * 5.9 + rgbarr[:,:,2] / 10 * 1.1
  grayscale[:,:,2] = rgbarr[:,:,0] / 10 * 3 + rgbarr[:,:,1] / 10 * 5.9 + rgbarr[:,:,2] / 10 * 1.1
  
  
  surface.unlock()
  new_surf = pygame.surfarray.make_surface(grayscale)
  
  
  
  
  screen_rect = screen.get_rect()
  surf_rect = surface.get_rect()
  
  screen.blit(new_surf, ((screen_rect.w - surf_rect.w) / 2, (screen_rect.h - surf_rect.h) / 2))
  
  while True:
    for event in pygame.event.get():
      if event.type == pygame.QUIT: sys.exit()
    pygame.display.update()
    pygame.time.wait(100)
